package com.zl.credit.controller;


import ch.qos.logback.core.net.SyslogOutputStream;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zl.credit.entity.CreditProgress;
import com.zl.credit.service.impl.CreditProgressServiceImpl;
import org.apache.ibatis.logging.stdout.StdOutImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.UUID;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author anonymous
 * @since 2020-07-14
 */
@Controller
@RequestMapping("/credit-progress")
public class CreditProgressController {

    @Autowired
    private CreditProgressServiceImpl progressService;

    /**
     * 根据用户名查询当前用户是否有正在申请的业务
     * 如果没有则进入到申请环节
     * 否则提示用户有正在申请的业务
     *
     * @param name
     * @return
     */
    @RequestMapping(value = "checkStatus", method = RequestMethod.GET)
    public String checkStatus(String name, Model model) {
        //获取等路的用户名
        name="张三10";
        CreditProgress progress = progressService.selectprogress(name);
        System.out.println(progress);
        if (progress == null) {//没有正在申请的业务
            System.out.println("没有正在申请的业务");
            //向申请进度表插入一条数据
            progressService.addprogress(name);
            model.addAttribute("name","张三10");
            return "apply1";
        } else {//有正在申请的业务
            System.out.println("有正在申请的业务");
        }
        return "err1";
    }

    /**
     * 查询当前登录用户的信用卡申请进度
     * 根据用户名查询申请进度
     * @return
     */

    @RequestMapping(value = "Queryprogress",method = RequestMethod.GET)
     String Queryprogress(String name,Model model){
        name="张三10";
         List<CreditProgress> list = progressService.Queryprogress(name);
         list.forEach(System.out::println);
         model.addAttribute("list",list);
         return "progress_info";
     }
}
